home *** CD-ROM | disk | FTP | other *** search
- #include "bbs.h"
- /* if flg > 0 then force save account */
- int Save_Account(struct User *hoozer, struct UserKeys *hoozer2, int uslot, int flg)
- {
- long slot,stat;
- BPTR fh;
- if(OnlineEdit && Whence_The_Logon>=REMOTE_LOGON)
- {
- sprintf(GSTR3,"\tSaved account %4d %s\n",hoozer->Slot_Number,hoozer->Name);
- CallersLog(GSTR3);
- }
- if(flg) { /* Force Save User Account */
- uslot-=1;
- slot = uslot;
-
- } else {
- if(hoozer->Slot_Number==0) return(FAILURE);
- slot=hoozer->Slot_Number-1;
- }
-
- //strcpy(GSTR1,Cmds->BBSLoc);
- //strcat(GSTR1,"User.Data");
- strcpy(GSTR1,UserDataLoc);
- fh=Open(GSTR1,MODE_OLDFILE);
- if(fh==NULL) return(FAILURE);
-
- stat=MySeek(fh,(((long)sizeof(struct User))*(long)slot),OFFSET_BEGINNING);
- if(stat!=(((long)sizeof(struct User))*(long)slot)) {
- Close(fh);
- return(FAILURE);
- }
-
- stat=Write(fh,(char *)hoozer,sizeof(struct User));
- if(stat!=sizeof(struct User)) {
- Close(fh);
- return(FAILURE);
- }
-
- Close(fh);
-
- //strcpy(GSTR1,Cmds->BBSLoc);
- //strcat(GSTR1,"User.keys");
- strcpy(GSTR1,UserKeyLoc);
- fh=Open(GSTR1,MODE_OLDFILE);
- if(fh==NULL) return(FAILURE);
-
- stat=MySeek(fh,(((long)sizeof(struct UserKeys))*(long)slot),OFFSET_BEGINNING);
- if(stat!=(((long)sizeof(struct UserKeys))*(long)slot)) {
- Close(fh);
- return(FAILURE);
- }
-
- if(hoozer->New_User) hoozer2->New_User=1;
- else hoozer2->New_User=0;
-
- stat=Write(fh,(char *)hoozer2,sizeof(struct UserKeys));
- if(stat!=sizeof(struct UserKeys)) {
- Close(fh);
- return(FAILURE);
- }
-
- Close(fh);
-
- return(SUCCESS);
- }
-